/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conventus;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Douglas Tybel
 */
@Entity
@Table(name = "topicos", catalog = "conventus", schema = "")
@NamedQueries({
    @NamedQuery(name = "Topicos.findAll", query = "SELECT t FROM Topicos t"),
    @NamedQuery(name = "Topicos.findByCodTopico", query = "SELECT t FROM Topicos t WHERE t.codTopico = :codTopico"),
    @NamedQuery(name = "Topicos.findByCodAta", query = "SELECT t FROM Topicos t WHERE t.codAta = :codAta"),
    @NamedQuery(name = "Topicos.findByCodResponsavel", query = "SELECT t FROM Topicos t WHERE t.codResponsavel = :codResponsavel"),
    @NamedQuery(name = "Topicos.findByTipoTopico", query = "SELECT t FROM Topicos t WHERE t.tipoTopico = :tipoTopico"),
    @NamedQuery(name = "Topicos.findByTopico", query = "SELECT t FROM Topicos t WHERE t.topico = :topico"),
    @NamedQuery(name = "Topicos.findBySequencia", query = "SELECT t FROM Topicos t WHERE t.sequencia = :sequencia"),
    @NamedQuery(name = "Topicos.findByDatPrevisao", query = "SELECT t FROM Topicos t WHERE t.datPrevisao = :datPrevisao"),
    @NamedQuery(name = "Topicos.findByDatConclusao", query = "SELECT t FROM Topicos t WHERE t.datConclusao = :datConclusao"),
    @NamedQuery(name = "Topicos.findByComunica", query = "SELECT t FROM Topicos t WHERE t.comunica = :comunica")})
public class Topicos implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "COD_TOPICO")
    private Integer codTopico;
    @JoinColumn(name="COD_ATA",referencedColumnName="COD_ATA")
    @ManyToOne
    private Atas codAta;
    @JoinColumn(name="COD_RESPONSAVEL",referencedColumnName="COD_MEMBRO")
    @ManyToOne
    private Membros codResponsavel;
    @Basic(optional = false)
    @Column(name = "TIPO_TOPICO")
    private String tipoTopico;
    @Basic(optional = false)
    @Column(name = "TOPICO")
    private String topico;
    @Basic(optional = false)
    @Column(name = "SEQUENCIA")
    private int sequencia;
    @Column(name = "DAT_PREVISAO")
    @Temporal(TemporalType.DATE)
    private Date datPrevisao;
    @Column(name = "DAT_CONCLUSAO")
    @Temporal(TemporalType.DATE)
    private Date datConclusao;
    @Basic(optional = false)
    @Column(name = "COMUNICA")
    private String comunica;
    @OneToMany(mappedBy = "codTopicoPai")
    private List<Topicos> topicosList;
    @JoinColumn(name = "COD_TOPICO_PAI", referencedColumnName = "COD_TOPICO")
    @ManyToOne
    private Topicos codTopicoPai;
    @JoinColumn(name = "COD_ATA", referencedColumnName = "COD_ATA", updatable = false, insertable = false)
    @ManyToOne
    private Atas codAta2;
    @OneToMany(mappedBy = "codTopico")
    private List<Historicos> historicosList;

    public Topicos() {
    }

    public Topicos(Integer codTopico) {
        this.codTopico = codTopico;
    }

    public Topicos(Integer codTopico, Atas codAta, Membros codResponsavel, String tipoTopico, String topico, int sequencia, String comunica) {
        this.codTopico = codTopico;
        this.codAta = codAta;
        this.codResponsavel = codResponsavel;
        this.tipoTopico = tipoTopico;
        this.topico = topico;
        this.sequencia = sequencia;
        this.comunica = comunica;
    }

    public Integer getCodTopico() {
        return codTopico;
    }

    public void setCodTopico(Integer codTopico) {
        Integer oldCodTopico = this.codTopico;
        this.codTopico = codTopico;
        changeSupport.firePropertyChange("codTopico", oldCodTopico, codTopico);
    }

    public Atas getCodAta() {
        return codAta;
    }

    public void setCodAta(Atas codAta) {
        Atas oldCodAta = this.codAta;
        this.codAta = codAta;
        changeSupport.firePropertyChange("codAta", oldCodAta, codAta);
    }

    public Membros getCodResponsavel() {
        return codResponsavel;
    }

    public void setCodResponsavel(Membros codResponsavel) {
        Membros oldCodResponsavel = this.codResponsavel;
        this.codResponsavel = codResponsavel;
        changeSupport.firePropertyChange("codResponsavel", oldCodResponsavel, codResponsavel);
    }

    public String getTipoTopico() {
        return tipoTopico;
    }

    public void setTipoTopico(String tipoTopico) {
        String oldTipoTopico = this.tipoTopico;
        this.tipoTopico = tipoTopico;
        changeSupport.firePropertyChange("tipoTopico", oldTipoTopico, tipoTopico);
    }

    public String getTopico() {
        return topico;
    }

    public void setTopico(String topico) {
        String oldTopico = this.topico;
        this.topico = topico;
        changeSupport.firePropertyChange("topico", oldTopico, topico);
    }

    public int getSequencia() {
        return sequencia;
    }

    public void setSequencia(int sequencia) {
        int oldSequencia = this.sequencia;
        this.sequencia = sequencia;
        changeSupport.firePropertyChange("sequencia", oldSequencia, sequencia);
    }

    public Date getDatPrevisao() {
        return datPrevisao;
    }

    public void setDatPrevisao(Date datPrevisao) {
        Date oldDatPrevisao = this.datPrevisao;
        this.datPrevisao = datPrevisao;
        changeSupport.firePropertyChange("datPrevisao", oldDatPrevisao, datPrevisao);
    }

    public Date getDatConclusao() {
        return datConclusao;
    }

    public void setDatConclusao(Date datConclusao) {
        Date oldDatConclusao = this.datConclusao;
        this.datConclusao = datConclusao;
        changeSupport.firePropertyChange("datConclusao", oldDatConclusao, datConclusao);
    }

    public String getComunica() {
        return comunica;
    }

    public void setComunica(String comunica) {
        String oldComunica = this.comunica;
        this.comunica = comunica;
        changeSupport.firePropertyChange("comunica", oldComunica, comunica);
    }

    public List<Topicos> getTopicosList() {
        return topicosList;
    }

    public void setTopicosList(List<Topicos> topicosList) {
        this.topicosList = topicosList;
    }

    public Topicos getCodTopicoPai() {
        return codTopicoPai;
    }

    public void setCodTopicoPai(Topicos codTopicoPai) {
        Topicos oldCodTopicoPai = this.codTopicoPai;
        this.codTopicoPai = codTopicoPai;
        changeSupport.firePropertyChange("codTopicoPai", oldCodTopicoPai, codTopicoPai);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTopico != null ? codTopico.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Topicos)) {
            return false;
        }
        Topicos other = (Topicos) object;
        if ((this.codTopico == null && other.codTopico != null) || (this.codTopico != null && !this.codTopico.equals(other.codTopico))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "conventus.Topicos[ codTopico=" + codTopico + " ]";
    }

    public Atas getCodAta2() {
        return codAta2;
    }

    public void setCodAta2(Atas codAta2) {
        Atas oldCodAta2 = this.codAta2;
        this.codAta2 = codAta2;
        changeSupport.firePropertyChange("codAta2", oldCodAta2, codAta2);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
